package com.teamone.addressbook.Utilities;

import java.io.Reader;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class Utility {

	private SqlMapClient sqlMap = null; 
	
	public Utility()
	{
		try
		{
			String resource = "com/teamone/addressbook/ibatis/sqlMap-config.xml";
			Reader reader = Resources.getResourceAsReader(resource);
			sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		}
		catch (Exception e)
		{
			System.out.println(e.getMessage());
		}
	}
	
	public Utility(String resource)
	{
		try
		{
			Reader reader = Resources.getResourceAsReader(resource);
			sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		}
		catch (Exception e)
		{
			System.out.println(e.getMessage());
		}
	}
	
	public SqlMapClient getSqlMapClient()
	{
		return sqlMap;
	}
}
